<?php
class Util_Guider{
    public function getGuiderInfoById($uid){
        $user_info = DB::select()
            ->from('user_v2_userinfo')
            ->where('uid','=',$uid)
            ->execute()
            ->current();

        $user_info2 = DB::select()
            ->from('user_v2')
            ->where('uid','=',$uid)
            ->execute()
            ->current();
        if($user_info2['telActive'] == 1){
            $mobile = '+'.$user_info2['telCode'].$user_info2['telNum'];
        }else{
            $mobile = $user_info['userPhone'];
        }
        $lang = array();
        foreach(explode(',',$user_info['language']) as $v){
            if($v == 1){
                $lang[] = '中文';
            }elseif($v == 2){
                $lang[] = '法文';
            }elseif($v == 3){
                $lang[] = '英文';
            }
        }

        $data = array(
            'userFamily'=>$user_info['userFamily'],
            'userName'=>$user_info['userName'],
            'userGender'=>$user_info['userGender']  ,
            'userAge'=>$user_info['userAge'],
            'nationality'=>$user_info['nationality'],
            'language'=>$lang,
            'introduction'=>$user_info['introduction'],
            'resideCity'=>$user_info['resideCity'],
            'resideTime'=>$user_info['resideTime'],
            'country'=>$user_info['country'],
            'code'=>$user_info['code'],
            'rcity'=>$user_info['rcity'],
            'addr'=>$user_info['addr'],
            'userPhone'=>$mobile,
            'mail'=>$user_info2['email'],
            'userIcon'=>$user_info2['userIcon'],
            'utype'=>'GUIDER',
        );

        return $data;
    }

    public function guiderAccount($uid){
        $account = DB::select()
            ->from('user_v2')
            ->where('uid','=',$uid)
            ->execute()
            ->current();
        return $account;
    }

    public function guiderIdentity($uid){
        $account = $this->guiderAccount($uid);

        $data = array(
            'identityPicture'=>$account['identityPicture'],
            'identityErea'=>$account['identityErea'],
            'identityName'=>$account['identityName'],
            'identityActive'=>$account['identityActive'],
        );

        return $data;
    }

    public function guiderPhone($uid){
        $account = $this->guiderAccount($uid);
        $data = array(
            'telCode'=>$account['telCode'],
            'telNum'=>$account['telNum'],
            'phone'=>'+'.$account['telCode'].$account['telNum'],
        );
        return $data;
    }

    public function guiderEmail($uid){
        $account = $this->guiderAccount($uid);
        if($account['active']){
            $data['email'] = $account['email'];
        }else{
            $data = '';
        }
        return $data;
    }

}